<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return=array();
	$info=$this->plugin_setting('basic');
	//从请求参数中获取code
	$code=$_RQ['code'];
	if(!$code){
		$message['error']=2;
	}else{
		//code被查询次数
		$count=pdo_count('jy_security_log',array('uniacid'=>$_SESSION['uniacid'],'code'=>$code));
		$isfirst=$count==0?1:0;
		$secury=$this->plugin_setting('secury');
		$logid=$this->check_code($code);
		$message['error'] = $logid?0:1;
		if($message['error'] == 0){
			$message['msg']='该产品属于正品！请放心使用！';
			$num=$secury['num'];
			if($num && $num<=$count){
				$message['error']=1;
				$message['msg']='O~该产品属于正品！但超过查询次数！';
			}
            $count++;
            $goods_id=pdo_getcolumn('jy_security_log',array('uniacid'=>$_SESSION['uniacid'],'id'=>$logid),'goods_id');
            $info['goods_title']=pdo_getcolumn('jy_security_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$goods_id),'title');
		}else{
			$message['msg']='O~！该产品非正品！';
		}
	}
    $info['count']=$count;
	$return['url']=custom_url('jy_security/search/main/',true);
	$return['hdps']=$info['hdps'][0];
	$return['info']=$info;
	$return['message']=$message;
	set_html('title','在线防伪溯源查询');
	exi($return);
}	
?>